package com.demo.test;

import org.junit.Test;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class 网络请求 {

    @Test
    public void request(){

        try {
            HttpRequest request = HttpRequest.newBuilder()
                    .uri(URI.create("http://43.155.144.240:80/merchantapi/v2/VC001001"))
                    .header("content-type", "application/json")
                    .method("POST", HttpRequest.BodyPublishers.ofString("{\r\n    \"encryptedRandomKey\": \"U1Y9oLAiDxXste7ql55/m7qLd7W9zqabJWA2rGek2LKQ8GKpxnyoV4LtaY2S2Aw9PpjREfsVDAzpeBR7I5dkZjU94+vrgUJI2Yfgeaf9X/GWzjR1ll0GVSXZgQ/SU2hUfr54fK6+yKNnDnUPYFGPizU9KyqkrDMQBRIYf1IR/+RLVdMIsXDwj5nLA9FwfcQOLJ+UiIRbnWHpRTH7Eqg1cWSNWPz8Zm4dAQertcDeKKAx6GFfmqlcWkuAV7hIH1hJlscu7tcxXbKySs7MsnZ+k32c0QaGHJXpKEPaoD8vemZx2pxOyZM1qq0fl5Na1xkRLFh/AVbwPofw9/c0hN1sYQ==\",\r\n    \"apiKey\": \"CD8D9B55376B5612B23AC282FF3EE6BC\",\r\n    \"signature\": \"NPiKY55dtMwlsDudoC4wYRKJ2+vvLK5Ycf1bIPh037G5J8CEbMs2aGjyxA5EfhhP0B8PBA1oLvbeqdG8+nwlhLNc4zcVsAd6Q7gHhKsauaflt2rH3CP7F6a2DohaE3ATxRErCgxzo5D+QWFT6Osum1i5s0jZF0o08HNdBD8+/1yx6tXDSoetlPfG3SX4bhUbBwiZ/pO1BQF3Tfn9RnX9+tfOdCibfgkt9hMMaqkTntTFkAPysJPPW6eUjpBZDcpCmC1HcU+YqKnSZ6dUghZIPOylPUf02avqI6zR5dpUpeXCQKW1dXLWqhvx2GGXs3ZD1Z0RHgo6DR2Z3BP+4y05Cw==\",\r\n    \"requestId\": \"1234\",\r\n    \"bizData\": \"btJxZYv/KVC8IAhVvtInb2QdqBhwVmmfrn6Fs6brVklTN65eFpVBmDbN1hQh9Fet+JILJPfgo4gtyi0GM60GTLYqkhaOwmFO7r9Ve2jH9GF/QR3Wy7f3lfakRiURdgZI\",\r\n    \"timestamp\": \"20240518223452\"\r\n}"))
                    .build();
            HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
            System.out.println(response.body());
        }catch (Exception e){
        }
    }
}
